#include "window/FileInformation.hpp"

FileInformation::FileInformation(CYFile* file, QWidget* parent) : QDialog(parent){
    this->vBox             = new QVBoxLayout();
    this->filenameLabel    = new QLabel(file->getFileName());

    this->hBox1            = new QHBoxLayout();
    this->imagesCountTitle = new QLabel("图片数量");
    this->imagesCountLabel = new QLabel(QString("%1张").arg(file->getImagesCount()));

    this->hBox2            = new QHBoxLayout();
    this->editCountTitle  = new QLabel("修改次数");
    this->editCountLabel  = new QLabel();

    this->hBox3            = new QHBoxLayout();
    this->savedTimeTitle   = new QLabel("保存时间");
    this->savedTimeLabel   = new QLabel(file->getSavedDate());

    this->vBox->addWidget(this->filenameLabel);
    this->vBox->addStretch();
    this->vBox->addLayout(this->hBox1);
    this->vBox->addLayout(this->hBox2);
    this->vBox->addLayout(this->hBox3);
    this->vBox->addStretch();

    this->hBox1->addWidget(this->imagesCountTitle);
    this->hBox1->addStretch();
    this->hBox1->addWidget(this->imagesCountLabel);

    this->hBox2->addWidget(this->editCountTitle);
    this->hBox2->addStretch();
    this->hBox2->addWidget(this->editCountLabel);

    this->hBox3->addWidget(this->savedTimeTitle);
    this->hBox3->addStretch();
    this->hBox3->addWidget(this->savedTimeLabel);

    this->filenameLabel->setAlignment(Qt::AlignCenter);

    if(file->getSavedCount() == 0){
        this->editCountLabel->setText("翻译完成");

    }else{
        this->editCountLabel->setText(QString("%1次").arg(file->getSavedCount()));

    }

    this->setLayout(this->vBox);
    this->setWindowTitle("文件信息");

}
